﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GomeeSoft.src.classes;

namespace GomeeSoft.src.control
{
    public partial class UCLabel : UserControl
    {
        [Browsable(true)]
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public override string Text
        {
            get
            {
                return label1.Text;
            }
            set
            {
                label1.Text = value;
                RelocateLabel();
            }
        }
        public UCLabel()
        {
            InitializeComponent();
            BackColor = Global.GetColor(Global.UCLabelBackColor);
            label1.ForeColor = Global.GetColor(Global.UCLabelForeColor);
            label1.BackColor = Color.Transparent;
            label1.Text = this.Name;
        }

        private void UCLabel_Load(object sender, EventArgs e)
        {
            RelocateLabel();
        }

        private void UCLabel_Resize(object sender, EventArgs e)
        {
            RelocateLabel();
        }

        private void RelocateLabel()
        {
            label1.Left = (Width - label1.Width) / 2;
            label1.Top = (Height - label1.Height) / 2;
            Invalidate();
        }
    }
}
